/**
 *	Copyright (c) 2009, SpLib.net
 * 	All rights reserved.
  	
 * 	Author:6spring
 * 	About:hurlant.crypto的简单包装
*/

package SpLib.Tools
{	
	import com.hurlant.crypto.Crypto;
	import com.hurlant.crypto.symmetric.ICipher;
	import flash.utils.ByteArray;
	
	public class crypto
	{
		public function crypto()
		{
		}
		
		public static function encrypt(data:ByteArray,name:String,key:ByteArray,padname:String = ""):void
		{
			var des3:ICipher;
			if(padname!=null && padname.length!=0) 
			{
				des3 = com.hurlant.crypto.Crypto.getCipher(name,key,com.hurlant.crypto.Crypto.getPad(padname));
			}
			else
			{
				des3 = com.hurlant.crypto.Crypto.getCipher(name,key);
			}
			
			if(des3!=null)
			{
				des3.encrypt(data);
			}
		}
		
		public static function decrypt(data:ByteArray,name:String,key:ByteArray,padname:String = ""):void
		{
			var des3:ICipher;
			if(padname!=null && padname.length!=0) 
			{
				des3 = com.hurlant.crypto.Crypto.getCipher(name,key,com.hurlant.crypto.Crypto.getPad(padname));
			}
			else
			{
				des3 = com.hurlant.crypto.Crypto.getCipher(name,key);
			}
			
			if(des3!=null)
			{
				des3.decrypt(data);
			}
		}
	}
}